<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>v-for</title>
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	</head>
	<body>
		<div id="app">
			<input type="button" value="添加数据" @click="add"/>
			<input type="button" value="移除数据" @click="remove"/>
			<ul>
				<li v-for="(item,index) in arr">
					小浩喜欢的第{{ index+1 }}个城市：{{item}}
				</li>
			</ul>
			<h2 v-for="item in objArr">
				{{ item.name }}
			</h2>
			
		</div>
		
		<script type="text/javascript">
			var app = new Vue({
				el: "#app",
				data:{
					arr:["北京","上海","广州","深圳"],
					objArr:[
						{name:"西兰花炒蛋"},
						{name:"蛋炒西兰花"}
					]
					
				},
				methods:{
					add:function(){
						this.objArr.push({name:"饭炒蛋"});
					},
					remove:function(){
						this.objArr.shift();
					}
				}
			})
		</script>
	</body>
</html>
